import util from '../../../utils/util'
import {
  ReportList
} from '../../../config/api'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[],
    uid: 0,
    isEmpty: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let member = wx.getStorageSync('member');
    if (!member){
      wx.redirectTo({
        url: '/pages/register/register',
      })
      return;
    }
    
    this.setData({
      uid: member.id
    })
    this.getList();
  },

  getList() {
    util.apiRequest(ReportList, {
      uid: this.data.uid
    }, null).then(r => {
      console.log("列表：", r)
      this.setData({
        list:r.data.data
      })
      if (r.data.data.length == 0) {
        this.setData({
          isEmpty:true
        })
      }
    })
  },

  enterDetail(e) {
    console.log(e)
    wx.navigateTo({
      url: '/pages/mine/epidemic-reporting/detail/detail?id='+e.currentTarget.dataset.id,
    })
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})